package com.car.web.listener;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.log4j.Logger;

import com.car.util.CommonUtil;
import com.car.util.Config;

public class MyServletContextListener implements ServletContextListener {
	private static final Logger logger = Logger
			.getLogger(MyServletContextListener.class);

	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		logger.debug("系统关闭"
				+ CommonUtil.getNowTimeString("yyyy/MM/dd HH:mm:ss"));

	}

	@Override
	public void contextInitialized(ServletContextEvent arg0) {
		ServletContext servlet_context = arg0.getServletContext();
		String contextPath = servlet_context.getContextPath();
		servlet_context.setAttribute("contextPath",contextPath);
		String base = servlet_context.getContextPath();
		servlet_context.setAttribute("base",base);
		String staticServer=Config.getString("resource.path");
		String staticServerUpload=Config.getString("resource.upload");
		servlet_context.setAttribute("staticServer",staticServer);
		servlet_context.setAttribute("staticServerUpload",staticServerUpload);
		//保存cookie域名
		String cookieDomain=Config.getString("cookie.domain","2schome.net");
		servlet_context.setAttribute("cookieDomain",cookieDomain);
		/**启动加载IP*/
	
		logger.debug("系统启动"
				+ CommonUtil.getNowTimeString("yyyy/MM/dd HH:mm:ss"));
		
	}
}
